
 set more off
 cd ""



  **************************************************************
  *    WOMEN'S REPRESENTATION & CORRUPTION REPLICATION FILES   *
  **************************************************************

  
  /* 
  
  This do file replicates the main analyses for the paper "Women’s Representation and Corruption: Evidence from Local Audits in Mexico"
   
  
  INPUT: Election models (election_models.dta) + modeling spending irregularities (spending_irregularities.dta)
  
  
  STRUCTURE OF DO FILE:
  
  
  1) ELECTION MODELS
  
  The effect of audit occurrence and revelations of corruption on the election of women
  
  Outcome: Woman mayor won election (0/1)
  
  Independent variables:
  - Recent audits
  - Recent revelations of corruption

  Controls:
  - Development
  - Population
  
  Model details:
  - Logistic regressions
  - State and year FE
  - Robust SE
  - Only include election years
  - No "usos y costumbres" municipalities
  
  
 
  
  2) SPENDING IRREGULARITIES
    
  Outcome: Irregularities uncovered (adjusted)  and log +1
  
  Independent variable:
  - Gender of the mayor
  
  Controls:
  - Development
  - Population
  - Funds
  - Previous audits
  - Parties
  
  Model details:
  - OLS
  - State and year FE
  - Robust SE
 
  
  */
 
 
 
 
 
 
 *******************************************************************************  1) ELECTION MODELS
 

 
 ********************* 1) AUDIT OCCURRENCE AND THE ELECTION OF WOMEN (FIGURE 4 upper panel)
 
 * Import data
 use "election_models.dta", clear
   

 * Save as temfile for later
 tempfile elec
 save `elec' 
  
  
 * Model 1 = Audit (t-1)
 * Model 2 = Audit (t-3)
 * Model 3 = Audit (t-2)
 * Model 3 = Ever audited
 
 * Audited (t-1)
 logit elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod4  
 
 
 ** TABLE
  # delimit ; 
  esti tab mod1 mod2 mod3 mod4, 
   star stats(N r2_p) keep(l_audit_year l_audit_2yr l_audit_3yr l_prev_audits_ever HDI lpop)
  ;
 
 
   * Coefficient plot
   #delimit ;

    coefplot mod1 mod2 mod3 mod4, xline(0)
	         keep(l_audit_year l_audit_2yr l_audit_3yr l_prev_audits_ever)
	         xlabel(-1(0.25)1, nogrid labsize(small)) levels(95 90)
			 ylabel(,nogrid)
		         ytitle("") 
				 title("Audit occurrence and the election of women")
	             xtitle("Probability of electing a woman") 
				 graphregion(color(white)) bgcolor(white)
				 xtitle("") name(g1, replace);	
  
 
 
   ** Regression table (appendix Table A7)
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women") addnote("Logistic regressions with cluster standard errors on municipalities") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 
 
 
 
 ********************* 2) REVELATIONS OF CORRUPTION AND THE ELECTION OF WOMEN (FIGURE 4 lower panel)
 
 
 * Model 1 = Audit occured and irregularities were found (t-1)
 * Model 2 = Audit occured and irreg found (t-3)
 * Model 3 = Revelations (t-1)
 * Model 4 = Revelations (t-3)
 
 
 * Model 1
 logit elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m1
 
 * Model 2
 logit elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m2
 
 * Model 3
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m3
 
 * Model 4
 logit elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m4
 
 
  
 ** TABLE
  # delimit ; 
  esti tab m1 m2 m3 m4, 
   star stats(N r2_p) keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop)
  ;
  

  
   * Coefficient plot
   #delimit ;

    coefplot m3 m4, xline(0)
	         keep(prev_auditreleased_1yr prev_auditreleased_3yr)
	         xlabel(-1(0.25)1, nogrid labsize(small)) levels(95 90)
			 ylabel(,nogrid)
		         ytitle("") 
				 title("Revelations of corruption and the election of women")
	             xtitle("") 
				 graphregion(color(white)) bgcolor(white)
				 xtitle("") name(g2, replace);	
  
 
  
  ** Regression table (appendix Table A8)
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 
  
  
 ** Coefficient plots together
 graph combine g1 g2, cols(1)
 

 ** Substantive effects
 
 * For Revelation (t-1)
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 margins, at(prev_auditreleased_1yr=(0(1)1)) atmeans 
 
 
 * 7.6-10.5%

  
  
   ** Marginsplot
  #delimit ;

    marginsplot, recast(scatter) recastci(rspike) 
	             xlabel(-1(1)2, nogrid labsize(small)) legend(off)
		         ytitle("Probability of female mayor winning") title("")
	             xtitle("Revealed audit in the past year") title("")
				 ylabel(0(.1).3, nogrid)
				 graphregion(color(white)) bgcolor(white)
				 xtitle("") name(s1, replace);	
   

   
  ** ELECTIONS WITH AT LEAST ONE WOMAN AS CANDIDATE (FIGURE 5)
  
  * Import number of women
  use "women_in_election.dta", clear
  
  ** Tempfile
  tempfile cand
  save `cand'
  

  
 ** MERGE WITH ELECTION DATA
 use "election_models.dta", clear
 
 ** Merge
 merge 1:1 cve_inegi year using `cand'
    
 * Keep matched cases
 keep if _merge==3
 drop _merge
  
 
 *** FIGURE 5
 
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 

 margins, at(prev_auditreleased_1yr=(0(1)1)) atmeans 
 
 * 15.9-20.9%

  #delimit ;

    marginsplot, recast(scatter) recastci(rspike) 
	             xlabel(-1(1)2, nogrid labsize(small)) legend(off)
		         ytitle("Probability of female mayor winning") title("")
	             xtitle("Revealed audit in the past 3 years") title("")
				 ylabel(0(.1).3, nogrid)
				 graphregion(color(white)) bgcolor(white)
				 xtitle("") name(s2, replace);	
  
  
  
  gr combine s1 s2

  
 
  

  

  
  
  
  
 
  ******************************************************************  2) MODELS FOR SPENDING IRREGULARITIES
 
 
   
  ** Import data
  use "spending_irregularities.dta", clear


  ********** TABLE 1
  
  
  * Model 1 = Just gender
  * Model 2 = Controls
  * Model 3 = No zero irreg
  * Model 4 = Log of irreg
  
  
  * Model 1
  reg irreg_adj gender i.state_ID i.year, robust 
  esti store mod1 
    
  
  * Model 2
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod2 
  
  * Model 3
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if irreg_adj~=0, robust
  esti store mod3 
  
  
  * Model 4
  reg ln1_irreg_adj gender HDI lpop universe_adj l_prevaudits  i.state_ID i.year, robust
  esti store mod4 


  
  ** TABLE
  # delimit ; 
  esti tab mod1 mod2 mod3 mod4, 
   star stats(N r2) keep(gender HDI lpop universe_adj l_prevaudits)
  ;
 
  
  ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Reported irregularities and gender of the mayor") addnote("OLS regressions with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(gender HDI lpop universe_adj l_prevaudits _cons) label
          coeflabels(gender "Woman mayor" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 

   
  
  
  
  
  

  
  
  
  
  
  
  
  
  
